package com.levy.contronller.jvm.classLoader;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Created by levy on 2019/6/14.
 */
public class MyTest20_1 {

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException, InterruptedException {

        MyClassLoader loader1 = new MyClassLoader("loader11");
        Class<?> clazz1 = loader1.loadClass("com.levy.contronller.jvm.classLoader.MyCat");
        System.out.println("class: " + clazz1.hashCode());
        Object o = clazz1.newInstance();
        System.out.println(o);

        System.out.println();

        loader1 = null;
        clazz1 = null;
        o = null;

        Thread.sleep(5000);

        System.gc();

        Thread.sleep(5000);

        loader1 = new MyClassLoader("loader12");
        clazz1 = loader1.loadClass("com.levy.contronller.jvm.classLoader.MyCat");
        System.out.println("class: " + clazz1.hashCode());
        o = clazz1.newInstance();
        System.out.println(o);


    }
}
